﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using WCYCReader.Resources;

namespace WCYCReader.Pages
{
    public partial class ErrorPage : PhoneApplicationPage
    {
        public ErrorPage()
        {
            InitializeComponent();
        }

        public static Exception Exception;

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.txtErrorInfo.Text = Exception.ToString();
            //this..Text = Exception.ToString();

        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {

            var msg = Exception.Message;

            while (null != Exception.InnerException)
            {
                Exception = Exception.InnerException;
                msg += (Exception.Message + Environment.NewLine);
            }

            var emailComposeTask = new EmailComposeTask
            {
                Subject = string.Concat(AppResources.ApplicationTitle, "爆掉了！！！"),
                Body = "Message: " + msg,
                To = "3122242921@qq.com"
            };
            emailComposeTask.Show();
        }
    }
}